package com.cdd.educms.controller;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.cdd.commonutils.R;
import com.cdd.educms.entity.CrmBanner;
import com.cdd.educms.service.CrmBannerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * 前台Banner管理
 * </p>
 *
 * @author cdd
 * @since 2021-02-11
 */
@RestController
@RequestMapping("/educms/bannerfront")
@CrossOrigin
public class BannerFrontController {

    @Autowired
    private CrmBannerService crmBannerService;

    // 分页获取Banner
    @GetMapping("getAllBanner")
    @Cacheable(key = "'selectIndexList'", value = "banner")
    public R getAllBanner() {
        QueryWrapper<CrmBanner> wrapper = new QueryWrapper<>();
        wrapper.orderByDesc("id");
        wrapper.last("limit 2");
        List<CrmBanner> list = crmBannerService.list(wrapper);
        return R.ok().data("list",list);
    }
}

